'''
实现栈结构, 先进先出
2021-8-17 Nasa
'''


class MyStack:
    def __init__(self):
        self.stack = []
        self.length = 0

    def push(self, thing):
        self.stack.append(thing)
        self.length += 1

    def pop(self):
        if self.length >= 1:
            thing = self.stack[-1]
            self.stack.remove(thing)
            self.length -= 1
            return thing
        return None

    def peek(self):
        if self.length >= 1:
            return self.stack[-1]
        return None

    def __repr__(self):
        return self.stack


if __name__ == '__main__':
    stack = MyStack()
    stack.push('a')
    stack.push('b')
    stack.pop()
    stack.pop()
    stack.pop()
    print(stack.peek())
